package com.example.demo1122.domain;

import com.example.demo1122.entity.Teacher;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.Collections;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class LoginTeacher implements UserDetails {

    private Teacher teacher;


//    @Override
//    public Collection<? extends GrantedAuthority> getAuthorities() {
//        return null;
//    }
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
    // 为教师硬编码角色
    return Collections.singletonList(new SimpleGrantedAuthority("ROLE_TEACHER"));
}
    @Override
    public String getPassword() {
        return teacher.getPassword();

    }

    @Override
    public String getUsername() {

        return teacher.getTeacherID();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}


